package cn.epsilon3.mybatis.service.impl;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import cn.epsilon3.domain.e3.po.E3UserSaltPo;
import cn.epsilon3.mybatis.mapper.E3UserSaltMapper;
import cn.epsilon3.mybatis.service.E3UserSaltMapperService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * user_salt mapper 服务
 * </p>
 *
 * @author epsilon3
 * @since 2023-08-16
 */
@Service
public class E3UserSaltMapperServiceImpl implements E3UserSaltMapperService {

    @Resource
    private E3UserSaltMapper userSaltMapper;

    @Override
    public String selectSaltByUserId(String userId) {
        if (StrUtil.isBlank(userId)) {
            return null;
        }
        E3UserSaltPo e3UserSaltPo = userSaltMapper.selectOne(
                Wrappers.<E3UserSaltPo>lambdaQuery()
                        .eq(E3UserSaltPo::getUserId, userId)
        );
        if (ObjectUtil.isNull(e3UserSaltPo)) {
            return null;
        }
        return e3UserSaltPo.getSalt();
    }
}
